﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace sdk_cop
{
    class AggregatePaymentRequestV3TestUI
    {

        ///APP_ID：通过内管查看详情，可获取对应的组织机构、接入方式、公钥等信息；APP管理中查看
        ///MY_PRIVATE_KEY:RSA私钥，可以通过sdk包下面bin文件夹里面的工具生成一对公私钥
        ///APIGW_PUBLIC_KEY:网关公钥
        protected static String APP_ID = "1000000000000026****";
        protected static String MY_PRIVATE_KEY = "";		
        protected static String APIGW_PUBLIC_KEY = "";
        protected static String SIGN_TYPE = "RSA2";
        protected static String PRIKEY = "PngZs9oRfkKa78A2A87YzQ==";//AES key
       
        protected static String ENCRYPT_TYPE = "AES";

        static void Main(string[] args)
        {
            /// <summary>
            /// 页面服务实现类(RSA加解密方式) 
            /// </summary>
            /// <param name="APP_ID">应用id</param>
            /// <param name="MY_PRIVATE_KEY">RSA私钥</param>
            /// <param name="APIGW_PUBLIC_KEY">网关公钥</param>
            /// <returns>页面服务实现类实例</returns>
            UiIcbcClient client = new UiIcbcClient(APP_ID, SIGN_TYPE , MY_PRIVATE_KEY, ENCRYPT_TYPE, PRIKEY, IcbcConstants.CHARSET_UTF8);
            ///新建服务请求类实例
            AggregatePaymentRequestV3 request = new AggregatePaymentRequestV3();
            ///新建服务请求类的业务参数类，该类为内部类
            AggregatePaymentRequestV3.AggregatePaymentRequestV3Biz bizContent = new AggregatePaymentRequestV3.AggregatePaymentRequestV3Biz();
            ///为请求类设置各种参数
          
            request.setServiceUrl(" https://gw.open.icbc.com.cn/ui/aggregate/payment/request/V3");
            bizContent.setMerId("12042699****");
            bizContent.setChannelId("");
            bizContent.setTpAppId("");
            bizContent.setTpOpenId("");
            bizContent.setPayLimit("");
            bizContent.setMerHint("");
            bizContent.setOutTradeNo("2018121219****");
            bizContent.setTranType("OfflinePay");
            bizContent.setOrderDate("20181212191732");
            bizContent.setEndTime("20181212221732"); 
            bizContent.setGoodsBody("芬达");
            bizContent.setGoodsDetail("{'good_name':'芬达橙味300ml罐装','good_id':'1001','good_num':'1'}");
            bizContent.setAttach("友宝");
            bizContent.setOrderAmount("1");
            bizContent.setInstallTimes("1");
            bizContent.setSpbillCreateIp("82.201.125.104");
            bizContent.setNotifyUrl("http://www.baidu.com");
            bizContent.setResultType("0");
            bizContent.setNotifyType("HS");
            bizContent.setReturnUrl("http://www.baidu.com");
            bizContent.setBackup1("");
            bizContent.setBackup2("");
            bizContent.setBackup3("");
            bizContent.setBackup4("");
            bizContent.setInterfaceVersion("1.0.0.2");

            request.setBizContent(bizContent);

            try
            {
                Console.WriteLine(client.buildPostForm(request));
            }
            catch (System.Net.WebException e) //无法连接到远程服务器，网络异常
            {
                throw e;
            }
            catch (Exception ex)//抛出其他异常
            {
                throw ex;
            }

        }
    }
}

